package artid.com.arttogo.adapter;

import java.util.List;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.ImageLoader.ImageListener;
import com.android.volley.toolbox.Volley;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;

import artid.com.arttogo.R;
import artid.com.arttogo.bean.InfoExpress;
import artid.com.arttogo.task.CallbackSky;

public class ExpressAdapter extends BaseAdapter {
	private Context mContext;
	LayoutInflater mInflater;
	ViewHolder holder;
	CallbackSky cs;
	public List<InfoExpress.Info> list;

	public ExpressAdapter(Context mContext, List<InfoExpress.Info> list) {
		this.mContext = mContext;
		DisplayMetrics dm = new DisplayMetrics();
		mInflater = LayoutInflater.from(mContext);
		this.list = list;
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return 0;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	public void addList(List<InfoExpress.Info> list) {
		this.list.addAll(list);
		notifyDataSetChanged();
	}

	ImageView imageShow;

	@SuppressLint("NewApi")
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {
		ViewHolder vh = null;
		System.out.println();
		if (convertView == null) {
			vh = new ViewHolder();
			convertView = mInflater.inflate(R.layout.item_express, null);
			vh.text = (TextView) convertView
					.findViewById(R.id.item_express_text);
			vh.time = (TextView) convertView
					.findViewById(R.id.item_express_time);
			vh.dot = (ImageView) convertView.findViewById(R.id.image_express);
			vh.dotorange = (ImageView)convertView.findViewById(R.id.image_express_orange);
			convertView.setTag(vh);
		} else {
			vh = (ViewHolder) convertView.getTag();
		}
		final InfoExpress.Info authNewsListItem = list.get(position);
		if (position == 0) {
			vh.text.setTextColor(Color.BLACK);
			vh.text.setTextSize(14);
			vh.dot.setVisibility(View.GONE);
			vh.dotorange.setVisibility(View.VISIBLE);
		}else {
			vh.text.setTextColor(Color.GRAY);
			vh.text.setTextSize(12);
			vh.dot.setVisibility(View.VISIBLE);
			vh.dotorange.setVisibility(View.GONE);
		}
		vh.text.setText(authNewsListItem.getContext());
		vh.time.setText(authNewsListItem.getTime());

		return convertView;
	}

	class ViewHolder {
		TextView text, time;
		ImageView dot,dotorange;

	}
}
